import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter);

const asynImport = (resolve,src,name) => require.ensure([],()=>resolve(require(src)),name)

const router = new VueRouter({
	// base:
	routes:[
		{
			path: '/home',name:'home',redirect:{name:'index'},
			component: s => require.ensure([],()=>s(require('../components/home/view')),'home'),
			// component: resolve => resolve(require('../components/home/view')),
			// resolve => require(['../components/home/home'],resolve),
			// Login(resolve){require.ensure([],() => {resolve(require('../components/login')),'component'})},
			children:[
				{
					path:'index',name:'index',redirect:{name:'order'},
					// component: s => require(['../components/home/index/view'],s),
					component: s => require.ensure([],()=>s(require('../components/home/index/view')),'home'),
					children:[
						{
							path:'order',name:'order',
							// component:s => require(['../components/home/index/index_order'],s)
							component: s => require.ensure([],()=>s(require('../components/home/index/index_order')),'home')
						},
						{
							path:'weiz',name:'weiz',
							component:s => require(['../components/home/index/index_weiz'],s)
						},
						{
							path:'meif',name:'meif',
							component:s => require(['../components/home/index/index_weiz'],s)
						},
						{
							path:'doc',name:'doc',
							component:s => require(['../components/home/index/index_weiz'],s)
						},
						{
							path:'hos',name:'hos',
							component:s => require(['../components/home/index/index_weiz'],s)
						},

					]
				}

			]
		},
		{
			path: '/login',name:'login',
			// component: s => require(['../components/home/login/login'],s)
			component: s => require.ensure([],()=>s(require('../components/home/view')),'home'),
		},
		{
			path:'*', redirect: './home'
		}
	],
	scrollBehavior (to, from, savedPosition) {
	    return { x: 0, y: 0 }
	}
})

export default router
